package com.wangsd.common.exception;

//包装器业务异常类实现
public class BusinessException extends RuntimeException implements BusinessError{

    private BusinessError businessError;

    //直接接受BusinessErrorEnum的传参用于构造业务异常
    public BusinessException(BusinessError businessError) {
        super();
        this.businessError = businessError;
    }

    //接受自定义errMessage的方式构造业务异常
    public BusinessException(BusinessError businessError, String errMessage) {
        super();
        this.businessError = businessError;
        this.businessError.setErrMessage(errMessage);
    }

    @Override
    public int getErrCode() {
        return this.businessError.getErrCode();
    }

    @Override
    public String getErrMessage() {
        return this.businessError.getErrMessage();
    }

    @Override
    public BusinessError setErrMessage(String message) {
        return this.businessError.setErrMessage(message);
    }
}
